package company.kedaxunfei;

import java.util.Scanner;

public class Ke1 {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int result = 0;
        int[] counts = new int[5];
        int[] nums = new int[]{1, 5, 10, 50, 100};
        for (int i = 0; i < 5; i++) {
            counts[i] = sc.nextInt();
        }
        int num = sc.nextInt();
        for (int i = 4; i >= 0; i--) {
            while (nums[i] <= num && counts[i] > 0) {
                num -= nums[i];
                counts[i]--;
                result++;
                if (num == 0) {
                    System.out.println(result);
                    return;
                }
            }
        }
        System.out.println(-1);
    }
}
